/**
 * 
 */
package com.disys.mb.support;

import java.io.Serializable;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import com.disys.facade.support.Rec140ERWOTCLOCSupportFacade;
import com.disys.mb.AbstractMB;
import com.disys.model.support.Rec140ERWOTCLOCSupport;

/**
 * @author Ubaid Raja
 *
 */
@ViewScoped
@ManagedBean(name="rec140ERWOTCLOCSupportMB")
public class Rec140ERWOTCLOCSupportMB extends AbstractMB implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = -4002698515072803607L;
	private Rec140ERWOTCLOCSupportFacade facade;
	private List<Rec140ERWOTCLOCSupport> list;
	private Rec140ERWOTCLOCSupport obj;
	
	private String rectype;
	private String cocode;
	private String tci_id;
	private String wotcfacilitybegindt;
	
	public Rec140ERWOTCLOCSupportMB(){
		facade = new Rec140ERWOTCLOCSupportFacade();
		obj = getObj();
		setRectype(obj.getRectype());
		setCocode(obj.getCocode());
		setTci_id(obj.getTci_id());
		setWotcfacilitybegindt(obj.getWotcfacilitybegindt());
	}
	/**
	 * @return the facade
	 */
	public Rec140ERWOTCLOCSupportFacade getFacade() {
		if(facade == null){
			return new Rec140ERWOTCLOCSupportFacade();
		}
		return facade;
	}
	
	public String update(){
		Rec140ERWOTCLOCSupport object = new Rec140ERWOTCLOCSupport();
		object.setCocode(cocode);
		object.setTci_id(tci_id);
		object.setRectype(rectype);
		object.setWotcfacilitybegindt(wotcfacilitybegindt);
		object.setId(obj.getId());
		try{
			facade.update(object);
			displayInfoMessageToUser("Record updated successfully!!!");
			return null;
		}catch(Exception e){
			displayErrorMessageToUser("Error updating record !!!");
			return null;
		}
	}
	
	public void cancel(){
		System.out.println("Cancel");
	}
	/**
	 * @return the list
	 */
	public List<Rec140ERWOTCLOCSupport> getList() {
		list = facade.findAllRecords();
		return list;
	}

	/**
	 * @param list the list to set
	 */
	public void setList(List<Rec140ERWOTCLOCSupport> list) {
		this.list = list;
	}

	/**
	 * @return the obj
	 */
	public Rec140ERWOTCLOCSupport getObj() {
		
		Rec140ERWOTCLOCSupport entity = getFacade().findSingleRecord();
		if(entity == null){
			entity = new Rec140ERWOTCLOCSupport();
		}
		return entity;
	}

	/**
	 * @param obj the obj to set
	 */
	public void setObj(Rec140ERWOTCLOCSupport obj) {
		this.obj = obj;
	}


	/**
	 * @return the cocode
	 */
	public String getCocode() {
		return cocode;
	}


	/**
	 * @param cocode the cocode to set
	 */
	public void setCocode(String cocode) {
		this.cocode = cocode;
	}
	/**
	 * @return the tci_id
	 */
	public String getTci_id() {
		return tci_id;
	}
	/**
	 * @param tci_id the tci_id to set
	 */
	public void setTci_id(String tci_id) {
		this.tci_id = tci_id;
	}
	/**
	 * @return the wotcfacilitybegindt
	 */
	public String getWotcfacilitybegindt() {
		return wotcfacilitybegindt;
	}
	/**
	 * @param wotcfacilitybegindt the wotcfacilitybegindt to set
	 */
	public void setWotcfacilitybegindt(String wotcfacilitybegindt) {
		this.wotcfacilitybegindt = wotcfacilitybegindt;
	}
	/**
	 * @return the rectype
	 */
	public String getRectype() {
		return rectype;
	}
	/**
	 * @param rectype the rectype to set
	 */
	public void setRectype(String rectype) {
		this.rectype = rectype;
	}
	
}
